home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
351-375
/
disk_361
/
xcolor-lib
/
demo_sources
/
demo_ii.s
< prev
next >
Wrap
Text File
|
1992-05-06
|
6KB
|
205 lines
;
;
; DEMO II - XColor library
;
;
; by Roger Fischlin
; Steigerwaldweg 6
; 6450 Hanau 7
; West Germany
;
;
; To run this demo the xcolor library must be available !
;
; This demo shows how you can use the user interface in
; assembler !
;
; user interface :
;
; · change colours using the cursor keys (up/down)
; · exit by pressing ESC
; · copy by pressing c
;
incdir "fh1:include/" ; path may be different
include "exec/exec_lib.i"
include "intuition/intuitionbase.i"
include "intuition/intuition.i"
include "intuition/intuition_lib.i"
include "fh1:Color/XColor.i"
include "misc/easystart.i" ; I love the Workbench !
move.l #XC_VERSION,d0 ; open library
lea.l XColorName(pc),a1
CALLEXEC OpenLibrary
tst.l d0
beq NoLibrary
move.l d0,_XColorBase
move.l d0,a0 ; XColor has already opened
move.l XCb_IntuitionBase(a0),a0 ; the Intuition-Library - so why should I
move.l ib_ActiveScreen(a0),d0 ; it a second time ????
lea.l Palette(pc),a0 ; put up ColorRequester structure
move.l d0,CR_Screen(a0) ; ^screen
move.b #0,CR_TextColour(a0) ; pens
move.b #1,CR_BackColour(a0)
move.b #2,CR_GBorderColour(a0)
move.b #0,CR_GTextColour(a0)
move.w #10,CR_LeftEdge(a0) ; X,Y
move.w #10,CR_TopEdge(a0)
move.l #4,CR_DefaultEntries(a0) ; default workbench palette
move.l #DefaultPalette,CR_DefaultColourMap(a0)
move.l #ScreenTitle,CR_ScreenTitle(a0) ; screen title
move.l #WindowTitle,CR_DefaultWTitle(a0) ; defalut window title
move.l #OpenWindow,CR_JMPWindow(a0) ; user interface
clr.l CR_JMPDraw(a0)
move.l #NewMode,CR_JMPMode(a0)
move.l #NewMessage,CR_JMPMessage(a0)
clr.l CR_Font(a0) ; use default font (should be 8x8)
move.l #FLAG_NORMAL!FLAG_HSV,CR_Flags(a0) ; don't use hex, but use HSV instead of RGB
CALLXCOLOR ColourRequester
move.l _XColorBase,a1 ; close library
CALLEXEC CloseLibrary
NoLibrary moveq.l #0,d0
rts
XColorName XCOLORNAME
_XColorBase dc.l 0
Palette ds.b CR_SIZEOF
even
DefaultPalette dc.w $05a,$fff,$000,$f80
even
ScreenTitle dc.b "DEMO - XCOLOR LIBRARY BY ROGER FISCHLIN",0
even
WindowTitle dc.b "Palette ",0
even
; user interface
;
;
; set RAWKEY, d0 contains pointer to NewWindow
;
OpenWindow move.l d0,a0 ; d0 = ^NewWindow
or.l #RAWKEY,nw_IDCMPFlags(a0) ; set RAWKEY
rts
;
; The requester obtained a message it couldn't use
;
NewMessage lea.l Palette(pc),a5 ; ColourRequester structure
cmp.l #RAWKEY,CR_imClass(a5) ; Class of message
bne .Nothing ; check if right message class
move.w CR_imCode(a5),d0 ; rawkey code of pressed key
btst #7,d0 ; key still pressed ?
beq .Nothing
and.w #$7f,d0 ; clear key-released-flag
cmp.b #$45,d0
beq .EXIT
cmp.b #$4c,d0 ; check key
beq .DOWN
cmp.b #$4d,d0
beq .UP
cmp.b #$33,d0
beq .COPY
.Nothing move.l #CR_NOTHING,d0 ; Do nothing !
rts
.EXIT move.l #CR_EXIT,d0 ; leave ColourRequester !
rts
.UP move.l CR_Screen(a5),a0 ; get screen pointer
CALLXCOLOR ColourNumber ; get mask (number-1)
subq.l #1,d0
sub.l #1,CR_Colour(a5) ; previous Colour
and.l d0,CR_Colour(a5) ; & mask
move.l #CR_NEWCOLOUR,d0 ; current colour has been changed !
rts
.DOWN move.l CR_Screen(a5),a0 ; get screen pointer
CALLXCOLOR ColourNumber ; get mask (number-1)
subq.l #1,d0
add.l #1,CR_Colour(a5) ; next Colour
and.l d0,CR_Colour(a5) ; & mask
move.l #CR_NEWCOLOUR,d0 ; current colour has been changed !
rts
.COPY cmp.l #1<<31+1,CR_Mode(a5) ; undo mode ?
beq .Undo
move.l #.CopyText,CR_WindowTitle(a5) ; set new window title
move.l #1<<31+1,CR_Mode(a5) ; set user mode (bit 31=1)
move.l #CR_NEWMODE,d0 ; new mode / window title
rts
.Undo move.l #0,CR_Mode(a5) ; clear mode
move.l CR_DefaultWTitle(a5),CR_WindowTitle(a5)
; set default window title
move.l #CR_NEWMODE,d0 ; new mode / window title
rts
.CopyText dc.b "Copy Colour To : ",0
even
NewMode lea.l Palette(pc),a5 ; ColourRequester structure
cmp.l #1<<31+1,CR_Mode(a5) ; ckeck if right mode !
bne .Nothing
move.l d0,d6 ; d0= selected colour
move.l CR_Screen(a5),a0
lea.l sc_ViewPort(a0),a0
move.l CR_Colour(a5),d0
CALLXCOLOR ReadRGB4 ; get RGB of source (current colour)
cmp.l #-1,d0 ; error ????????
beq .Nothing
move.l d0,d1
move.l d6,d0
move.l CR_Screen(a5),a0
lea.l sc_ViewPort(a0),a0
CALLXCOLOR WriteRGB4 ; write RGB
move.l _XColorBase,a6
move.l XCb_IntuitionBase(a6),a6 ; get Intuition library base
jsr _LVORemakeDisplay(a6) ; remake display
clr.l CR_Mode(a5) ; clear mode
move.l CR_DefaultWTitle(a5),CR_WindowTitle(a5) ; set window title
move.l d6,CR_Colour(a5) ; destimation as new colour
move.l #CR_NEWCOLOUR,d0
rts
.Nothing move.l #CR_NOTHING,d0 ; Do nothing !
rts